#include "PointTranslator.h"

PointTranslator::PointTranslator(int zoom)
	: _zoom(zoom)
{
}

int PointTranslator::zoom() const
{
	return _zoom;
}

void PointTranslator::setZoom(int z)
{
	_zoom = z;
}

QPoint PointTranslator::toscreen(const QPoint& p) const
{
	return QPoint(p.x() * _zoom, p.y() * _zoom);
}

QSize PointTranslator::toscreen(const QSize& s) const
{
	return QSize(s.width() * _zoom, s.height() * _zoom);
}

QPoint PointTranslator::tological(const QPoint& p) const
{
	// Note that the truncation in this division is actually what we want.
	// Screen points [0,zoom) are part of logical 0.
	
	return QPoint(p.x() / _zoom, p.y() / _zoom);
}

QSize PointTranslator::tological(const QSize& s) const
{
	// Note that the truncation in this division is actually what we want.
	// Screen points [0,zoom) are part of logical 0.
	
	return QSize(s.width() / _zoom, s.height() / _zoom);
}

